/*String.prototype.type = 'String';
Number.prototype.type = 'Number';
Object.prototype.type = 'Object';
Array.prototype.type = 'Array';
Function.prototype.type = 'Function';
Date.prototype.type = 'Date';
RegExp.prototype.type = 'RegExp';
Event.prototype.type = 'Event';
Error.prototype.type = 'Error';*/
/**
 *	字符串的格式化输出
 **/
String.prototype.sprintf = function(){
	var str = this;
	var argsize = arguments.length;
	for(var i = 0 ; i < argsize ; i++){
		var index = str.search(/%/i);
		if(index >= 0){          
			var start = str.substring(0,index);
			var end = str.substring(index+2);
			var type = str.substring(index+1,index+2);
			if(type == 'd'){
					str = start + parseInt(arguments[i]) + end;
			}else{
					str = start + (arguments[i] ?  arguments[i] : "") + end;
			}
		}
	}
	return str;
}

/**
 *	对象生产url对象
 **/
Object.prototype.toURL = function(pre){
	var str = "";
	var obj = this;
	for(var i in obj){
		switch(typeof obj[i]){
			case 'object':
				if(pre){
					str += obj[i].toURL(pre + "[" + i + "]");
				}else{
					str += obj[i].toURL(i)
				}
				break;
			case 'function':
				break;
			default :
				if(pre){
					str += "&%s[%s]=%s".sprintf(pre,i,obj[i]);
				}else{
					str += "&%s=%s".sprintf(i,obj[i]);			
				}
		}
	}
	return str;
}
/**
 *	判断元素是不是存在该数组
 **/
Array.prototype.in = function(obj){
	for(var i in this){
		ir(this[i] == obj){
			return true;
		}
	}
	return false;
}
/**
 *	获取数组的长度
 **/
Array.prototype.size = function(){
	return this.lengthl
}
(function GHG(){
	this.sleep = function(func,timeout,arg){
		window.setTimeout(function(){func(arg);},1000*timeout);
	}
	//this.animation = function()

	window.G = this;
})();

